<?php
namespace Admin\Model;
use Think\Model;
header("Content-Type:text/html; charset=utf-8");
class UserModel extends Model {
	protected $autoCheckFields = false;  //关闭字段信息的自动检测
	public function index(){	
		
		$list = array(
				'title' =>'基因科技',	
				'ext'=>$a,
					);
		
		return $list;
	}
	//获取用户列表
	public function user_list(){
		$User = M('User'); // 实例化User对象
		$keyword=trim(I('keyword'));
		$where="(nickname LIKE '%".$keyword."%' or openid LIKE '%".$keyword."%' or province LIKE '%".$keyword."%')";
		$count      = $User->where($where)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数(25)
		$show       = $Page->show();// 分页显示输出
		// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$list = $User->limit($Page->firstRow.','.$Page->listRows)->where($where)->order('subscribe_time desc')->select();
		$acticle=M('acticle');
		$arr=array();
		foreach ($list as $key => $value) {
			$uid=$value['id'];
			$acticle_num=$acticle->where('uid='.$uid)->count();
			//print_r($acticle_num);exit;
			$value['num']=$acticle_num;
			$arr[]=$value;
		}
		$arr=array('page'=>$show,'count'=>$count,'list'=>$arr);
		return $arr;
	}
	//获取单条用户信息
	public function operate(){
		$uid=I('uid');
		$user=M('user');
		$list=$user->where('id='.$uid)->find();
		/*echo M()->_sql();
		print_r($list);exit;*/
		if (empty($list)) {
			return 'false';
		}
		return $list;

	}

}
?>